var mongoose = require('mongoose');
var User = require('../../server/models/user.js');
var Image = require('../../server/models/image.js')
mongoose.connect('mongodb://localhost:27017/photo');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.on('open',function(){
    console.log('db is connect')
})
var user = new User({name: '123',password: '123'});
User.create(user, function(err, _user){
    if (err){
        console.info(err)
    }
})
//User.find({},function(err,_user){
//    console.log(_user)
//
//})

//Image.create(image, function(err,_image){
//    if(err) console.log(err)
//    console.log(_image)
//})
//Image.findOne({name: '左耳', function(err, _image){
//    if(err) console.log(err)
//    console.log(_image)
//}})

//var image = new Image({name: '左耳', desc: '·医学专家说左耳是靠近心脏最近的地方，甜言蜜语要说给左耳听。'})
///*image.save(function(err) {
// if(err) console.log(err)
// } )*/
//Image.create(image, function(err) {
//    if(err) console.log(err)
//} )
//Image.find({}, function (err, _image) {
//    if(err) {
//        console.log(err)
//    }
//    console.log(_image)
//
//})